﻿import com.dmotiko.general.*
import mx.transitions.easing.Regular;
import mx.transitions.Tween;

class LoaderBarControl
extends LoaderControl {
	
	private var txt:TextField;
	private var mcBar:MovieClip;
	private var mcBack:MovieClip;
	private var nPercent:Number;
	
	private function initClip():Void {
		super.initClip();
		mcBar._width = 0;
		nPercent = 0;
		this._visible = false;
	}
	
	public function onLoadStart() {
		this._visible = true;
		mcBar._width = 0;
		txt.text = "loading";
	}
	
	public function onLoadComplete() {
		this._visible = false;
	}
	
	private function refreshData():Void {
		nPercent = Number( getData() );
		txt.text = nPercent + "%";
		registerTween("barWidth", new Tween(mcBar, "_width", Regular.easeOut, mcBar._width, nPercent * mcBack._width / 100, 0.3, true));
	}
	
}